package com.whjz.dcfs.ggts.dao;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.whjz.dcfs.ggts.model.DcfsTsclTsjcsjJbxx;
import com.whjz.dcfs.util.PageParam;

@Repository
public class DcfsTsclTsjcsjJbxxDAO implements IDcfsTsclTsjcsjJbxxDAO{

    @Autowired
    private SqlMapClient sqlMapClient;

    public void deleteDcfsTsclTsjcsjJbxxByCond(DcfsTsclTsjcsjJbxx object) throws SQLException{
        sqlMapClient.delete("deleteDcfsTsclTsjcsjJbxxByCond", object);
    }

    public void deleteDcfsTsclTsjcsjJbxxListByCond(List<DcfsTsclTsjcsjJbxx> list) throws SQLException{
        if (null != list) {
			sqlMapClient.startBatch();
            for (int i = 0; i < list.size(); i++) {
                deleteDcfsTsclTsjcsjJbxxByCond(list.get(i));
            }
			sqlMapClient.executeBatch();
        }
    }

    public List<DcfsTsclTsjcsjJbxx> getDcfsTsclTsjcsjJbxxListByCond(DcfsTsclTsjcsjJbxx object) throws SQLException{
        return sqlMapClient.queryForList("getDcfsTsclTsjcsjJbxxByCond", object);
    }

    public PageParam queryPageInfo(DcfsTsclTsjcsjJbxx object,PageParam pageParam) throws SQLException{
		pageParam.setPageIndex(pageParam.getPageIndex());
		object.setPageIndex(pageParam.getPageIndex());
		object.setPageLast(pageParam.getPageLast());
		int totalCount = ((Integer)sqlMapClient.queryForObject("queryDcfsTsclTsjcsjJbxxCount",object)).intValue();
		List<DcfsTsclTsjcsjJbxx> list = sqlMapClient.queryForList("queryDcfsTsclTsjcsjJbxxPage",object);
		pageParam.setResult(list);
		pageParam.setTotalCount(totalCount);
		pageParam.setTotalPage(pageParam.getTotalPage());
		return pageParam;
    }

	public void insertDcfsTsclTsjcsjJbxx(DcfsTsclTsjcsjJbxx object)
			throws SQLException {
		sqlMapClient.insert("insertDcfsTsclTsjcsjJbxx", object);
	}

}
